package com.pc.controller;

import com.pc.entity.Notice;
import com.pc.service.NoticeService;
import com.pc.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 李林雨
 * @createTime 2023/12/27 20:59
 * @description
 */
@RestController
@RequestMapping("notice")
public class NoticeController {
    @Resource
    private NoticeService noticeService;
    //获得公告
    @GetMapping("getNotice")
    public Result getNotice(){
        Notice notice = noticeService.getNotice();
        return Result.success("查询成功",notice.getContent());
    }
    //新增公告
    @PostMapping("addNotice")
    public Result addNotice(@RequestBody Notice notice){
         if(noticeService.insertNotice(notice))
            return Result.success("插入公告成功");
        else
            return Result.fail("插入公告失败");
    }
}
